package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.Comment;
import com.cskaoyan.bean.CommentListVO;
import com.cskaoyan.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin/comment")
public class CommentController {
    @Autowired
    CommentService commentService;

    /**
     * 商品品论首页
     *
     * @param page
     * @return
     */
    @RequestMapping("list")
    public BaseRespVo commentList(Integer page, Integer limit, String sort, String order, Integer userId, Integer valueId) {
        CommentListVO<Comment> commentListVO = commentService.queryCommentList(page, limit, sort, order, userId, valueId);
        return BaseRespVo.ok(commentListVO);
    }

    @RequestMapping("delete")
    public BaseRespVo deleteComment(@RequestBody Comment comment) {
        int delete = commentService.deleteComment(comment);
        if (delete==1){
            return BaseRespVo.ok();
        }
        return BaseRespVo.fail("删除失败");
    }
}
